home *** CD-ROM | disk | FTP | other *** search
- // =================================================================================
- // CActiveXApp.cpp ©1996 Microsoft Corporation. All rights reserved.
- // portions ©1995 Metrowerks Inc. All rights reserved.
- // =================================================================================
-
- #include <LGrowZone.h>
- #include <LMenu.h>
- #include <LMenuBar.h>
- #include <LString.h>
- #include <LWindow.h>
- #include <PP_Messages.h>
- #include <PPobClasses.h>
- #include <UDesktop.h>
- #include <UDrawingState.h>
- #include <UMemoryMgr.h>
- #include <UReanimator.h>
- #include <URegistrar.h>
- #include <UTextTraits.h>
-
- #include "ActiveXAppConstants.h"
- #include "CActiveXDocument.h"
- #include "CActiveXView.h"
- #include "urlapi.h"
-
- #ifdef MULTI_CONTEXT_TEST_APP
- #include "CActiveXShadowView.h"
- #endif // MULTI_CONTEXT_TEST_APP
-
- #include "CActiveXApp.h"
-
- #include <compobj.h>
-
- CActiveXApp *CActiveXApp::sDefaultApplication = NULL;
-
- // =================================================================================
- // • Main Program
- // =================================================================================
-
- void
- main( void )
- {
- // Initialize the heap. Parameter is number
- // of master handle blocks to allocate.
- InitializeHeap( 4 );
-
- // Initialize the MacOS toolbox.
- UQDGlobals::InitializeToolbox( &qd );
-
- // Install a GrowZone function to catch low memory situations.
- // Parameter is the size of the memory reserve in bytes.
- new LGrowZone( 20000 );
-
- // Create the application object and run it.
- CActiveXApp theApp;
-
- theApp.Run();
- }
-
-
- // ---------------------------------------------------------------------------------
- // • CActiveXApp
- // ---------------------------------------------------------------------------------
-
- CActiveXApp::CActiveXApp()
- {
- // Setup the throw and signal actions.
- SetDebugThrow_( debugAction_Alert );
- SetDebugSignal_( debugAction_Alert );
-
- // Give global access to the application object
- sDefaultApplication = this;
-
- // Register PowerPlant class creator functions.
- RegisterAllPPClasses();
-
- // Register custom classes.
- URegistrar::RegisterClass( CActiveXView::class_ID, (ClassCreatorFunc) CActiveXView::CreateActiveXViewStream );
- #ifdef MULTI_CONTEXT_TEST_APP
- URegistrar::RegisterClass( CActiveXShadowView::class_ID, (ClassCreatorFunc) CActiveXShadowView::CreateActiveXShadowViewStream );
- #endif // MULTI_CONTEXT_TEST_APP
- OpenUrlMoniker(NULL);
- }
-
-
- // ---------------------------------------------------------------------------------
- // • ~CActiveXApp
- // ---------------------------------------------------------------------------------
-
- CActiveXApp::~CActiveXApp()
- {
- CloseUrlMoniker();
- }
-
-
- // ---------------------------------------------------------------------------------
- // • StartUp
- // ---------------------------------------------------------------------------------
-
- void
- CActiveXApp::StartUp()
- {
- ObeyCommand( cmd_New, nil );
- }
-
-
- // ---------------------------------------------------------------------------------
- // • FindCommandStatus
- // ---------------------------------------------------------------------------------
-
- void
- CActiveXApp::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName )
- {
- switch ( inCommand ) {
-
- case cmd_PageSetup:
- {
- // Short circuit the page setup command
- // since this example doesn't print.
- outEnabled = false;
- }
- break;
-
- default:
- {
- // Call inherited.
- LDocApplication::FindCommandStatus( inCommand,
- outEnabled, outUsesMark, outMark, outName );
- }
- break;
-
- }
- }
-
-
- // ---------------------------------------------------------------------------------
- // • OpenDocument
- // ---------------------------------------------------------------------------------
-
- void
- CActiveXApp::OpenDocument(
- FSSpec *inMacFSSpec )
- {
- // Create a new document using the file spec.
- new CActiveXDocument( this, inMacFSSpec );
- }
-
-
- // ---------------------------------------------------------------------------------
- // • MakeNewDocument
- // ---------------------------------------------------------------------------------
-
- LModelObject *
- CActiveXApp::MakeNewDocument()
- {
- // Make a new empty document.
- return new CActiveXDocument( this, nil );
- }
-
-
- // ---------------------------------------------------------------------------------
- // • ChooseDocument
- // ---------------------------------------------------------------------------------
-
- void
- CActiveXApp::ChooseDocument()
- {
- // Deactivate the desktop.
- ::UDesktop::Deactivate();
-
- // Browse for a document.
- SFTypeList theTypeList = {'TEXT'};
- StandardFileReply theReply;
- ::StandardGetFile( nil, 1, theTypeList, &theReply );
-
- // Activate the desktop.
- ::UDesktop::Activate();
-
- // Send an apple event to open the file.
- if ( theReply.sfGood ) SendAEOpenDoc( theReply.sfFile );
- }
-